package com.zretc.util;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Created by Administrator on 2020/8/22.
 */
@Component
public class RBMQSender {
    private String senderId;

    public String getSenderId() {
        return senderId;
    }

    public void setSenderId(String senderId) {
        this.senderId = senderId;
    }

    private static RBMQSender rs;

    @PostConstruct
    public void init(){
        rs = this;
    }
    @Autowired
    private AmqpTemplate template;

    public void send(String receiveUser,String msg) {
        rs.template.convertAndSend("topic.message",msg);
        rs.template.convertAndSend("topic.messages",msg);
        System.out.println(" RBMQSender");
    }
}
